import requests
from lxml import etree
import os

def decomplie(filename):
    url = 'http://tools.bugscaner.com/api/decompyle/'
    Session = requests.session()
    headers = {
        'User-Agent':'Mozilla/5.0 (Linux; Android 6.0.1; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Mobile Safari/537.36'
    }
    fd = open(filename, 'rb')
    files = {
                'pyc':fd
            }
    resp = Session.post(url=url, headers=headers, files=files)
    json_dict = resp.json()
    html = json_dict.get('info')
    tree = etree.HTML(html)
    code = tree.xpath('//text()')[0]
    file_front, _ = os.path.splitext(filename)
    with open(file_front+'.py', 'w', encoding='UTF-8') as fp:
        fp.write(code)